home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 1 / Meeting Pearls Vol 1 (1994).iso / amok98-106 / amok105 / hotkey / hotkeytest.mod < prev    next >
Text File  |  1994-05-03  |  2KB  |  70 lines

  1. (*---------------------------------------------------------------------------
  2. :Program.    HotKeyTest
  3. :Author.     Thomas Igracki
  4. :Address.    Obstallee 45, 1000 Berlin 20, W-Germany
  5. :E-Mail.     T.IGRACKI@BAMP.ZER
  6. :Version.    V1.0  28-Apr-92  Thomas Igracki  erste Veröffentlichung
  7. :Version.    V2.0  21-Dec-92  [tom]          angepaßt an HotKey.mod V2.0
  8. :Copyright.  Thomas Igracki
  9. :Language.   Oberon
  10. :Translator. Amiga Oberon 3.00d
  11. :Contents.   TestProgramm für das HotKey Modul.
  12. :Usage.      [Run] TestHotKey
  13. :Remark.     Needs OS2.04 or higher!
  14. ---------------------------------------------------------------------------*)
  15. MODULE HotKeyTest;
  16. IMPORT
  17.       s:   SYSTEM,
  18.       c:   Commodities,
  19.       d:   Dos,
  20.       e:   Exec,
  21.       hot: HotKey,
  22.        io;
  23. CONST
  24.    ID1 = 0; ID2 = -5;
  25. VAR
  26.    ls         : LONGSET;
  27.    HotSig     : SHORTINT;
  28.    ID         : LONGINT;
  29.    Type      : LONGSET;
  30.  
  31. BEGIN
  32.      IF ~hot.CheckCVersion(0) THEN HALT(20) END;
  33.      HotSig := hot.InitX ('HotKeyTest','Commodity Test','A test of the HotKey-Modul',{hot.notify,hot.unique},TRUE,10);
  34.      IF HotSig = -1 THEN
  35.        io.WriteString ('Init() failed error code: ');
  36.        io.WriteInt(hot.Error,0);
  37.        io.WriteLn;
  38.        HALT(20);
  39.      END;
  40.  
  41.      IF ~hot.AddKey ("alt 1",ID1) THEN io.WriteString ('AddKey() failed\n'); HALT(20) END;
  42.      IF ~hot.AddKey ("alt 2",ID2) THEN io.WriteString ('AddKey() failed\n'); HALT(20) END;
  43.      hot.Activate (TRUE);
  44.  
  45.      io.WriteString ('Press Alt-1 or Alt-2\nBreak with Ctrl-C, or ExChange or call me again!\n');
  46.      LOOP
  47.      ls := e.Wait (LONGSET{HotSig,d.ctrlC});
  48.      IF d.ctrlC IN ls THEN io.WriteString ('Break detected!\n'); EXIT END;
  49.      IF HotSig  IN ls THEN
  50.         WHILE hot.GetCMsg(Type,ID) DO
  51.           IF hot.command IN Type THEN
  52.         CASE ID OF
  53.           hot.cAppear    : io.WriteString ('ShowInterface\n')|
  54.           hot.cDisappear: io.WriteString ('HideInterface\n')|
  55.           hot.cKill    : io.WriteString('Ciao!\n'); HALT(0)|
  56.           hot.cUnique: io.WriteString('Not Uniq. I better quit\n'); HALT(0)|
  57.         ELSE
  58.         END;
  59.           ELSIF hot.hotkey IN Type THEN
  60.         CASE ID OF
  61.            ID1 : io.WriteString ('Alt 1 pressed!\n')|
  62.            ID2 : io.WriteString ('Alt 2 pressed!\n')|
  63.         ELSE
  64.         END;
  65.           END;
  66.         END;
  67.      END;
  68.      END
  69. END HotKeyTest.
  70.